<%--
  Created by IntelliJ IDEA.
  User: gaoliwei02
  Date: 17/6/25
  Time: 上午10:31
  To change this template use File | Settings | File Templates.
--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>single device information</title>

    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/button_demo1.css">
</head>

<body>
<!-- Content Header (Page header) -->
<section class="content-header">
    <h1>
        single device information
        <small>page</small>
    </h1>
</section>

<section class="content">
    <div class="box" id="devid_view">
        <div class="box-body ">

            <div class="col-lg-12  col-xs-12" >
                <h2 class="col-lg-12  col-xs-12">device id input:</h2>

                <div class="col-lg-2  col-xs-12">
                    <input type="text" class="form-control" id="device_input">
                </div>

                <div class="col-lg-1  col-xs-12">
                    <b class="form-control a_demo_two" onclick="check()">check</b>
                </div>
            </div>
        </div>
    </div>

    <div class="box">
        <%--<div class="box-header with-border"></div><!-- /.box-header -->--%>
        <div class="box-body ">

            <%--<div class="row " style=" margin-top: -10px;margin-bottom: -5px">--%>
            <%--<div class="col-lg-12  col-xs-12">--%>
            <%--<h3>工厂临时修改DEVID: </h3>--%>
            <%--</div>--%>

            <%--<div class="col-lg-2  col-xs-6">--%>
            <%--<label>修改新的DEVID</label>--%>
            <%--<input type="text" class="form-control" id="newdevid_msg">--%>
            <%--</div>--%>

            <%--<div class="col-lg-2  col-xs-6">--%>
            <%--<label class="col-lg-12  col-xs-12">发送新devid</label>--%>
            <%--<b  type="button" class="a_demo_two col-lg-6  col-xs-6" id="send_newdevid_msg" onclick="send_newdevid_msg_btn()">发送新devid</b>--%>
            <%--</div>--%>
            <%--</div>--%>

            <hr>
            <div class="row " style=" margin-top: -10px;margin-bottom: -5px">
                <div class="col-lg-12  col-xs-12">
                    <h3>control code: </h3>
                </div>

                <div class="col-lg-2  col-xs-6">
                    <label>send ctrl_msg</label>
                    <input type="text" class="form-control" id="control_msg">
                </div>

                <div class="col-lg-2  col-xs-6">
                    <label class="col-lg-12  col-xs-12">send_msg</label>
                    <b type="button" class="a_demo_two col-lg-6  col-xs-6" id="send_msg" onclick="send_msg_btn()">send_msg</b>
                </div>
            </div>

            <%--<hr>--%>
            <%--<div class="row" style=" margin-top: -10px;margin-bottom: -5px">--%>

                <%--<div class="col-lg-12  col-xs-12">--%>
                    <%--<h3>control button: </h3>--%>
                <%--</div>--%>

                <%--<div class="col-lg-2  col-xs-6">--%>
                    <%--<label class="open_btn" style="margin-bottom: 10px">open_btn</label>--%>
                    <%--<b type="button" class="a_demo_two" onclick="ab_open_btn(0)">open</b>--%>
                <%--</div>--%>

                <%--<div class="col-lg-2  col-xs-6">--%>
                    <%--<label class="close_btn" style="margin-bottom: 10px">close_btn</label>--%>
                    <%--<b type="button" class="a_demo_two" onclick="ab_close_btn(0)">close</b>--%>
                <%--</div>--%>

            <%--</div>--%>

            <%--<hr>--%>
            <%--<div class="row" style=" margin-top: -10px;margin-bottom: -5px">--%>

                <%--<div class="col-lg-12  col-xs-12">--%>
                    <%--<h3>A/B control button: </h3>--%>
                <%--</div>--%>

                <%--<div class="col-lg-3  col-xs-3">--%>
                    <%--<label style="margin-bottom: 10px">open_A</label>--%>
                    <%--<b type="button" class="a_demo_two" onclick="ab_open_btn(1)">A open</b>--%>
                <%--</div>--%>

                <%--<div class="col-lg-3  col-xs-3">--%>
                    <%--<label style="margin-bottom: 10px">close_A</label>--%>
                    <%--<b type="button" class="a_demo_two" onclick="ab_close_btn(1)">A close</b>--%>
                <%--</div>--%>

                <%--<div class="col-lg-3  col-xs-3">--%>
                    <%--<label style="margin-bottom: 10px">open_B</label>--%>
                    <%--<b type="button" class="a_demo_two" onclick="ab_open_btn(2)">B open</b>--%>
                <%--</div>--%>

                <%--<div class="col-lg-3  col-xs-3">--%>
                    <%--<label style="margin-bottom: 10px">close_B</label>--%>
                    <%--<b type="button" class="a_demo_two" onclick="ab_close_btn(2)">B close</b>--%>
                <%--</div>--%>
                <%----%>
            <%--</div>--%>

            <hr>
            <div class="row" style=" margin-top: -10px;margin-bottom: -5px">

                <div class="col-lg-12  col-xs-12">
                    <h3>device info_list: </h3>
                </div>

                <div class="col-lg-12  col-xs-12">
                    <table class="table">
                        <caption>device info table</caption>
                        <thead>
                        <tr>
                            <th>key</th>
                            <th>value</th>
                        </tr>
                        </thead>

                        <tbody>
                        <tr>
                            <td>deviceId</td>
                            <td id="m_deviceId"></td>
                        </tr>
                        <tr>
                            <td>imei</td>
                            <td id="m_imei"></td>
                        </tr>
                        <tr>
                            <td>mac</td>
                            <td id="m_mac"></td>
                        </tr>
                        <tr>
                            <td>poiid</td>
                            <td id="m_poiid"></td>
                        </tr>
                        <tr>
                            <td>onlineStatus</td>
                            <td id="m_onlineStatus"></td>
                        </tr>
                        <tr>
                            <td>reportTime</td>
                            <td id="m_reportTime"></td>
                        </tr>
                        <tr>
                            <td>registerTime</td>
                            <td id="m_registerTime"></td>
                        </tr>
                        <tr>
                            <td>otaTime</td>
                            <td id="m_otaTime"></td>
                        </tr>
                        <tr>
                            <td>orderCreateTimeA</td>
                            <td id="m_orderCreateTimeA"></td>
                        </tr>
                        <tr>
                            <td>orderCreateTimeB</td>
                            <td id="m_orderCreateTimeB"></td>
                        </tr>
                        <tr>
                            <td>orderDurationSecA</td>
                            <td id="m_orderDurationSecA"></td>
                        </tr>
                        <tr>
                            <td>orderDurationSecB</td>
                            <td id="m_orderDurationSecB"></td>
                        </tr>
                        <tr>
                            <td>sigQuality</td>
                            <td id="m_sigQuality"></td>
                        </tr>
                        <tr>
                            <td>errorInfo</td>
                            <td id="m_errorInfo"></td>
                        </tr>
                        <tr>
                            <td>batteryLevel</td>
                            <td id="m_batteryLevel"></td>
                        </tr>
                        <tr>
                            <td>batteryTemperature</td>
                            <td id="m_batteryTemperature"></td>
                        </tr>
                        <tr>
                            <td>batteryStatus</td>
                            <td id="m_batteryStatus"></td>
                        </tr>
                        <tr>
                            <td>batteryCycleTime</td>
                            <td id="m_batteryCycleTime"></td>
                        </tr>
                        <tr>
                            <td>batteryVoltage</td>
                            <td id="m_batteryVoltage"></td>
                        </tr>
                        <tr>
                            <td>location</td>
                            <td id="m_location"></td>
                        </tr>
                        <tr>
                            <td>isGpsFix</td>
                            <td id="m_isGpsFix"></td>
                        </tr>
                        <tr>
                            <td>mVersion</td>
                            <td id="m_mVersion"></td>
                        </tr>
                        <tr>
                            <td>fVersion</td>
                            <td id="m_fVersion"></td>
                        </tr>
                        <tr>
                            <td>miscMessage</td>
                            <td id="m_miscMessage"></td>
                        </tr>
                        <tr>
                            <td>userIdA</td>
                            <td id="m_userIdA"></td>
                        </tr>
                        <tr>
                            <td>userIdB</td>
                            <td id="m_userIdB"></td>
                        </tr>
                        <tr>
                            <td>orderIdA</td>
                            <td id="m_orderIdA"></td>
                        </tr>
                        <tr>
                            <td>orderIdB</td>
                            <td id="m_orderIdB"></td>
                        </tr>
                        <tr>
                            <td>statusA</td>
                            <td id="m_statusA"></td>
                        </tr>
                        <tr>
                            <td>statusB</td>
                            <td id="m_statusB"></td>
                        </tr>
                        <tr>
                            <td>chargeIn</td>
                            <td id="m_chargeIn"></td>
                        </tr>


                        </tbody>
                    </table>
                </div>

            </div>
        </div>
    </div>

</section>
<!-- /.content -->

<script>
    var deviceId = ${ model['deviceId']};

    $(document).ready(function () {
        if (deviceId == 0) {
            $("#devid_view").show();
        } else {
            $("#devid_view").hide();
            getDeviceDetail(deviceId);
            setInterval("getDeviceDetail(deviceId)", 30000);
        }
    });

    function check() {
        getDeviceDetail($("#device_input").val());
    }

    function getDeviceDetail(deviceId) {
        var send_data = {
            deviceId: deviceId,
        };
        send_json_data = (JSON.stringify(send_data));

        $.ajax({
            type: 'POST',
            url: "/single/getinfo.inner",
            contentType: 'application/json',
            dataType: "json",
            data: send_json_data,
            timeout: 10000,
            success: function (data) {
                var dataObj = eval(data);
                $("#m_deviceId").html(dataObj.deviceId);
                $("#m_imei").html(dataObj.imei);
                $("#m_mac").html(dataObj.mac);
                $("#m_poiid").html(dataObj.poiid);
                $("#m_onlineStatus").html(dataObj.onlineStatus);
                $("#m_reportTime").html(dataObj.reportTime);
                $("#m_registerTime").html(dataObj.registerTime);
                $("#m_otaTime").html(dataObj.otaTime);
                $("#m_orderCreateTimeA").html(dataObj.orderCreateTimeA);
                $("#m_orderCreateTimeB").html(dataObj.orderCreateTimeB);
                $("#m_orderDurationSecA").html(dataObj.orderDurationSecA);
                $("#m_orderDurationSecB").html(dataObj.orderDurationSecB);

                $("#m_sigQuality").html(dataObj.sigQuality);
                $("#m_errorInfo").html(dataObj.errorInfo);
                $("#m_batteryLevel").html(dataObj.batteryLevel);
                $("#m_batteryTemperature").html(dataObj.batteryTemperature);
                $("#m_batteryStatus").html(dataObj.batteryStatus);
                $("#m_batteryCycleTime").html(dataObj.batteryCycleTime);
                $("#m_batteryVoltage").html(dataObj.batteryVoltage);
                $("#m_location").html(dataObj.location);

                $("#m_isGpsFix").html(dataObj.isGpsFix);
                $("#m_mVersion").html(dataObj.mVersion);
                $("#m_fVersion").html(dataObj.fVersion);
                $("#m_miscMessage").html("<a href=\"javascript:getLocation()\">" + dataObj.miscMessage + "</a>");
                $("#m_userIdA").html(dataObj.userIdA);
                $("#m_userIdB").html(dataObj.userIdB);
                $("#m_orderIdA").html(dataObj.orderIdA);
                $("#m_orderIdB").html(dataObj.orderIdB);
                $("#m_statusA").html(dataObj.statusA);
                $("#m_statusB").html(dataObj.statusB);
                $("#m_chargeIn").html(dataObj.chargeIn);
//                alert(JSON.stringify(dataObj));
            }
        });
    }
</script>


<script>
    var ctrl_inner = "/single/ctrl.inner";
    var msg_inner = "/single/msg.inner";
    var send_json_data;
    var send_data;

//    function ab_open_btn(aorb) {
//        send_data = {
//            which: aorb,
//            click: "open",
//            deviceId: devid
//        };
//        send_json_data = (JSON.stringify(send_data));
//
//        $.ajax({
//            type: 'POST',
//            url: ctrl_inner,
//            contentType: 'application/json',
//            dataType: "json",
//            data: send_json_data,
//            timeout: 10000,
//            success: function (data) {
//                var dataObj = eval(data);
//                if (dataObj.status == 1) {
//                    alert("send open msg ok!");
//                }
//            }
//        });
//    }
//    function ab_close_btn(aorb) {
//        send_data = {
//            which: aorb,
//            click: "close",
//            deviceId: devid
//        };
//        send_json_data = (JSON.stringify(send_data));
//
//        $.ajax({
//            type: 'POST',
//            url: ctrl_inner,
//            contentType: 'application/json',
//            dataType: "json",
//            data: send_json_data,
//            timeout: 10000,
//            success: function (data) {
//                var dataObj = eval(data);
//                if (dataObj.status == 1) {
//                    alert("send close msg ok!");
//                }
//            }
//        });
//    }

    function send_msg_btn() {
        send_data = {
            msg: $("#control_msg").val(),
            deviceId: deviceId
        };
        send_json_data = (JSON.stringify(send_data));

        $.ajax({
            type: 'POST',
            url: msg_inner,
            contentType: 'application/json',
            dataType: "json",
            data: send_json_data,
            timeout: 10000,
            success: function (data) {
                var dataObj = eval(data);
                if (dataObj.status == 1) {
                    alert("send close msg ok!");
                }
            }
        });
    }

    function send_newdevid_msg_btn() {
        send_data = {
            newid: $("#newdevid_msg").val(),
            deviceId: deviceId
        };
        send_json_data = (JSON.stringify(send_data));

        $.ajax({
            type: 'POST',
            url: msg_inner,
            contentType: 'application/json',
            dataType: "json",
            data: send_json_data,
            timeout: 10000,
            success: function (data) {
                var dataObj = eval(data);
                if (dataObj.status == 1) {
                    alert("send close msg ok!");
                }
            }
        });
    }
</script>
</body>
</html>
